//
//  CellGroupController.m
//  MyBus
//
//  Created by Dinah Challen on 26/01/2009.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "CellGroupController.h"


@implementation CellGroupController

@synthesize menuItems;
@synthesize heading;

- (id) initWithMenuItems:(NSArray*)items heading:(NSString*)h {
	self = [super init];
	if (self) {
		self.menuItems = items;
		self.heading = h;
	}
	return self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
	return [menuItems count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	return [[menuItems objectAtIndex:indexPath.row] tableView:tableView cellForRowAtIndexPath:indexPath];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	[[menuItems objectAtIndex:indexPath.row] tableView:tableView didSelectRowAtIndexPath:indexPath];
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
	return heading;
}

- (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath {
	return [[menuItems objectAtIndex:indexPath.row] tableView:tableView accessoryTypeForRowWithIndexPath:indexPath];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
	return [[menuItems objectAtIndex:indexPath.row] tableView:tableView heightForRowAtIndexPath:indexPath];
}



@end
